package fun.util.daohelper.hibernate.expression;

import fun.util.daohelper.expression.LessThan;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

/**
 * Author: binz
 * Date: Jul 24, 2006
 * Time: 1:24:15 PM
 */
public class LessThanTransformer implements ExpressionCriterionTransformer<LessThan> {

    public Criterion transform( LessThan lessThan ) {
        if ( lessThan.isAndEqualTo() ) {
            return Restrictions.le( lessThan.getFieldName(), lessThan.getValue() );
        } else {
            return Restrictions.lt( lessThan.getFieldName(), lessThan.getValue() );
        }
    }
}
